From b2b8ea70db4ff231806d1eace7c6ae1c10017a9d Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Mon, 31 Oct 2011 12:36:51 +0000 Subject: [PATCH] Introduce the PreferencesGetLegend hook. I need this to customize the labels of
s in the preferences for the Gadgets extension in the RL2 branch and I can't think of a cleaner way to do this. --- docs/hooks.txt | 4 ++++ includes/Preferences.php | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/docs/hooks.txt b/docs/hooks.txt index 7eeed9f020..17e8c26eb7 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1486,6 +1486,10 @@ $subject : subject of the new section &$text : text of the new section Return false and put the merged text into $text to override the default behavior. +'PreferencesGetLegend': Override the text used for the of a preferences section +$key: the section name +&$legend: the legend text. Defaults to wfMsg( "prefs-$key" ) but may be overridden + 'PrefixSearchBackend': Override the title prefix search used for OpenSearch and AJAX search suggestions. Put results into &$results outparam and return false. $ns : array of int namespace keys to search in diff --git a/includes/Preferences.php b/includes/Preferences.php index 853643c85e..6b2d919170 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -1565,4 +1565,14 @@ class PreferencesForm extends HTMLForm { function getBody() { return $this->displaySection( $this->mFieldTree, '', 'mw-prefsection-' ); } + + /** + * Get the for a given section key. Normally this is the + * prefs-$key message but we'll allow extensions to override it. + */ + function getLegend( $key ) { + $legend = parent::getLegend( $key ); + wfRunHooks( 'PreferencesGetLegend', array( $key, &$legend ) ); + return $legend; + } } -- 2.20.1